package com.cskaoyan.dbutils.resultSetHandler;

import com.cskaoyan.bean.Account;
import com.cskaoyan.datasource.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 * 创建日期: 2022/07/02 11:00
 *
 * @author ciggar
 */
public class BeanHandlerDemo {

    public static void main(String[] args) throws SQLException {

        // 1. 获取QueryRunner
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());


        // 2. 执行SQL语句
        Account account = queryRunner.query("select id as uid,name,money from account", new BeanHandler<>(Account.class));


        // 输出结果
        System.out.println(account);

    }
}
